﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Icms.Core.Model;
using Icms.Core.Repository;
using Icms.Core.Service;
using Icms.Infra;
using Icms.Resources;

namespace Icms.WebUI.Controllers
{
    public static class Globals
    {
        public static Case Case(this Guid id)
        {
            return IoC.Resolve<IRepo<Case>>().Get(id);
        }

        public static bool IsJudge(this User user)
        {
            return user.Roles.Where(o => o.Name == "Judge").Count() > 0;
        }

        public static Court Court()
        {
            return IoC.Resolve<IUserService>().GetCourt(HttpContext.Current.User.Identity.Name);
        }

        public static User User()
        {
            return IoC.Resolve<IUserService>().GetByLogin(HttpContext.Current.User.Identity.Name);
        }

        public static IEnumerable<SelectListItem> DateIntervals()
        {
            return new List<SelectListItem>
                       {
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Undefined, Value = "0"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Current_week, Value = "1"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Previous_week, Value = "2"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Current_month, Value = "3"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Previous_month, Value = "4"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Current_quartal, Value = "5"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Previous_quartal, Value = "6"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Current_year, Value = "7"},
                           new SelectListItem {Text = Mui.Globals_DateIntervals_Previous_year, Value = "8"}
                       };
        }
    }
}